﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KingRoad.EPM.Web.Areas.SafetyConstruction.ViewModels;
using KingRoad.EPM.Web.Areas.SafetyConstruction.SafetyConstructionFramework.Common;
using KingRoad.EPM.SafetyManagementEntity.Model;
using System.Dynamic;

using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using System.Text;
using NPOI.SS.Util;
using System.IO;



namespace KingRoad.EPM.Web.Areas.SafetyConstruction.Controllers
{
    public class ScmThreePersonnelController : BaseController
    {
        public const string RYGL_SGRY = "AQHB_SLRY";
        //
        // GET: /ScmThreePersonnel/
        /// <summary>
        /// 三类人员台账 tzgl_slry
        /// </summary>
        /// <returns></returns>
        public ActionResult ThreePersonnelIndex()
        {
            var model = new ScmThreePersonnelViewModel();
            //施工单位列表
            model.TheUnitList = GetUnitListByType(1); ;
            return View(model);
        }

        //public ActionResult List()
        //{
        //    return View();
        //}
        // GET: /ScmThreePersonnel/
        /// <summary>
        /// 三类人员台账 tzgl_slry
        /// </summary>
        /// <returns></returns>
        public ActionResult ThreePersonnelList(string Section)
        {
            var puu = GetUnitInfoByCode(Section);
            ViewBag.Section = Section;
            ViewBag.unitid = puu.UNIT_ID;
            ViewBag.unitname = puu.UNIT_NAME;
            int totalRecord = 0;
            //当前页码
            ViewBag.pageNum = 1;
            //每页多少条
            ViewBag.numPerPage = 20;
            var list = ScmThreepersonnelUIRule.GetListForPage(ViewBag.pageNum, ViewBag.numPerPage, "Tp_Time", out totalRecord, "Tp_Section='" + ViewBag.Section + "'");
            int tempTotalRecord = 0;
            var allList = ScmThreepersonnelUIRule.GetListForPage(1, ALL_RECORD_ITEMS, "Tp_Time", out tempTotalRecord, "Tp_Section='" + ViewBag.Section + "'");
            SetSectionValue(RYGL_SGRY, allList);
            //总条数
            ViewBag.totalcount = totalRecord;
            //总页数
            ViewBag.pagenumshown = totalRecord % ViewBag.numPerPage == 0 ? totalRecord / ViewBag.numPerPage : totalRecord / ViewBag.numPerPage + 1;
            return View(new ScmThreePersonnelViewModel { ThreePersonnelList = list });
        }
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="vm"></param>
        /// <returns></returns>
        public ActionResult SplitPage(ScmThreePersonnelViewModel vm)
        {
            int totalRecord = 0;
            //当前页码
            ViewBag.pageNum = Convert.ToInt32(Request.Form["pageNum"]);
            //每页多少条
            ViewBag.numPerPage = Convert.ToInt32(Request.Form["numPerPage"]);
            ViewBag.name = Request.Form["name"];
            ViewBag.post = Request.Form["post"];
            ViewBag.Section = Request.Form["input_section"];
            var puu = GetUnitInfoByCode(ViewBag.Section);
            ViewBag.unitname = puu.UNIT_NAME;
            string sql = " 1=1 ";
            if (ViewBag.name != "")
                sql += " and Tp_Name like '%" + ViewBag.name + "%' ";
            if (ViewBag.post != "")
                sql += " and Tp_Post like '%" + ViewBag.post + "%' ";
            if (ViewBag.Section!="")           
                sql += " and Tp_Section='"+ViewBag.Section+"' ";
          
           
            var list = ScmThreepersonnelUIRule.GetListForPage(ViewBag.pageNum, ViewBag.numPerPage, "Tp_Time", out totalRecord, sql);
            int tempTotalRecord = 0;
            var allList = ScmThreepersonnelUIRule.GetListForPage(1, ALL_RECORD_ITEMS, "Tp_Time", out tempTotalRecord, sql);
            SetSectionValue(RYGL_SGRY, allList);
            //总条数
            ViewBag.totalcount = totalRecord;
            //总页数
            ViewBag.pagenumshown = totalRecord % ViewBag.numPerPage == 0 ? totalRecord / ViewBag.numPerPage : totalRecord / ViewBag.numPerPage + 1;
            return View("ThreePersonnelList", new ScmThreePersonnelViewModel { ThreePersonnelList = list });
        }
        /// <summary>
        /// 台账-添加 
        /// 功能：显示添加页面
        /// </summary>
        /// <returns></returns>
        public ActionResult ThreePersonnelAdd(string Section)
        {
            var puu = GetUnitInfoByCode(Section);
            ViewBag.unitid = puu.UNIT_ID;
            ViewBag.unitname = puu.UNIT_NAME;
            List<SelectListItem> sexlist = new List<SelectListItem>();
            sexlist.Add(new SelectListItem { Text = "男", Value = "男" });
            sexlist.Add(new SelectListItem { Text = "女", Value = "女" });
            ViewBag.sexlist = sexlist;

            List<SelectListItem> list = new List<SelectListItem>();
            list.Add(new SelectListItem { Text = "选择", Value = "null" });
            list.Add(new SelectListItem { Text = "是", Value = "True" });
            list.Add(new SelectListItem { Text = "否", Value = "False" });
            ViewBag.list = list;
            ViewBag.section = Section;
            return View();
        }
        /// <summary>
        /// 台账-添加 
        /// 功能：执行添加操作
        /// </summary>
        /// <returns></returns>
        public JsonResult ThreePersonnelAddData(ScmThreePersonnelViewModel vm)
        {
            var isScuess = TryCatchCommand.TryExec(() =>
            {
                vm.ThreePersonnelInfo.Tp_ID = Guid.NewGuid().ToString();
                vm.ThreePersonnelInfo.Tp_UserID = GetLoginUserId;              //操作人ID及名称 添加权限时赋值
                vm.ThreePersonnelInfo.Tp_UserName = GetLoginUserRealName;
                vm.ThreePersonnelInfo.Tp_Time = DateTime.Now;
                bool info = ScmThreepersonnelUIRule.InsertEntity(vm.ThreePersonnelInfo);
            });

            dynamic jsonReturn = new ExpandoObject();

            //保存成功
            if (isScuess)
            {
                jsonReturn = new
                {
                    statusCode = "200",
                    message = "添加成功",
                    navTabId = "SafetyConstruction.ScmThreePersonnel.ThreePersonnelList",
                    rel = "",
                    callbackType = "closeCurrent",
                    forwardUrl = "",
                    confirmMsg = ""
                };
            }
            else
            {
                jsonReturn = new
                {
                    statusCode = "300",
                    message = "添加失败",
                };
            }

            return new JsonResult()
            {
                Data = jsonReturn
            };
        }
        public JsonResult ThreePersonnelDelete(string id)
        {
            var isScuess = TryCatchCommand.TryExec(() =>
            {
                var st = ScmThreepersonnelUIRule.DeleteEntity(id);
            });
            dynamic jsonReturn = new ExpandoObject();
            //删除成功
            if (isScuess)
            {
                jsonReturn = new
                {
                    statusCode = "200",
                    message = "删除成功",
                    navTabId = "tzgl_fxpg_list",
                    rel = "",
                    callbackType = "",
                    forwardUrl = "",
                    confirmMsg = ""
                };
            }
            else
            {
                jsonReturn = new
                {
                    statusCode = "300",
                    message = "删除失败",
                };
            }
            return new JsonResult()
            {
                Data = jsonReturn
            };
        }
        /// <summary>
        /// 台账-批量删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult ThreePersonnelMultiDelete()
        {
            dynamic jsonReturn = new ExpandoObject();
            var ids = base.GetRequestFormValue<string>("ids");
            var isScuess = TryCatchCommand.TryExec(() =>
            {
                bool info = ScmThreepersonnelUIRule.DeleteEntityByMultiStringID(ids);
            });

            //保存成功
            if (true)
            {
                jsonReturn = new
                {
                    statusCode = "200",
                    message = "删除成功",
                    navTabId = "SafetyConstruction.ScmThreePersonnel.ThreePersonnelList",
                    rel = "",
                    callbackType = "",
                    forwardUrl = "",
                    confirmMsg = ""
                };
            }
            else
            {
                jsonReturn = new
                {
                    statusCode = "300",
                    message = "删除失败",
                };
            }
            return new JsonResult()
            {
                Data = jsonReturn
            };
        }
        /// <summary>
        /// 台账——编辑
        /// 功能：根据id加载相对应数据
        /// </summary>
        /// <returns></returns>
        public ActionResult ThreePersonnelEdit(Guid id)
        {
            var info = ScmThreepersonnelUIRule.GetInfoByID(id);
            List<SelectListItem> sexlist = new List<SelectListItem>();
            sexlist.Add(new SelectListItem { Text = "男", Value = "男" });
            sexlist.Add(new SelectListItem { Text = "女", Value = "女" });
            ViewBag.sexlist = sexlist;

            List<SelectListItem> list = new List<SelectListItem>();
            list.Add(new SelectListItem { Text = "选择", Value = "null" });
            list.Add(new SelectListItem { Text = "是", Value = "True" });
            list.Add(new SelectListItem { Text = "否", Value = "False" });          
            ViewBag.list = list;
            return View(new ScmThreePersonnelViewModel { ThreePersonnelInfo = info });
            //return View("SafeProductionAdd");
        }
        /// <summary>
        /// 台账-编辑（保存工作） 
        /// 功能：执行保存数据
        /// </summary>
        /// <returns></returns>
        public JsonResult ThreePersonnelEditData(ScmThreePersonnelViewModel vm)
        {
            var isScuess = TryCatchCommand.TryExec(() =>
            {
                vm.ThreePersonnelInfo.Tp_UserID = GetLoginUserId;              //操作人ID及名称 添加权限时赋值
                vm.ThreePersonnelInfo.Tp_UserName = GetLoginUserRealName;
                vm.ThreePersonnelInfo.Tp_Time = DateTime.Now;
                bool info = ScmThreepersonnelUIRule.UpdateEntity(vm.ThreePersonnelInfo);
            });

            dynamic jsonReturn = new ExpandoObject();

            //保存成功
            if (isScuess)
            {
                jsonReturn = new
                {
                    statusCode = "200",
                    message = "更新成功",
                    navTabId = "SafetyConstruction.ScmThreePersonnel.ThreePersonnelList",
                    rel = "",
                    callbackType = "closeCurrent",
                    forwardUrl = "",
                    confirmMsg = ""
                };
            }
            else
            {
                jsonReturn = new
                {
                    statusCode = "300",
                    message = "更新失败",
                };
            }

            return new JsonResult()
            {
                Data = jsonReturn
            };
        }
        /// <summary>
        /// 台账——查看
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        public ActionResult ThreePersonnelDetail(Guid id)
        {
            var info = ScmThreepersonnelUIRule.GetInfoByID(id);
            //ViewBag.unit = info.Tp_UnitName;
            return View(new ScmThreePersonnelViewModel { ThreePersonnelInfo = info });
        }

        #region Excel导入、导出
        /// <summary>
        /// Excel导出
        /// </summary>
        /// <returns></returns>
        public FileResult Excel(string Section, string unitname)
        {
            //获取list数据           
           // var list = ScmThreepersonnelUIRule.GetAllThreePersonnelBySection(" Tp_Section = '" + Section + "' order by Tp_Time asc");
            var list = GetSessionValue<List<ScmThreepersonnelInfo>>(RYGL_SGRY);
            //创建Excel文件的对象
            NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
            //添加一个sheet
            NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
            //列宽度
            sheet1.SetColumnWidth(0, 8 * 256);
            sheet1.SetColumnWidth(1, 15 * 256);
            sheet1.SetColumnWidth(2, 15 * 256);
            sheet1.SetColumnWidth(3, 15 * 256);
            sheet1.SetColumnWidth(4, 15 * 350);
            sheet1.SetColumnWidth(5, 15 * 256);
            sheet1.SetColumnWidth(6, 15 * 256);
            sheet1.SetColumnWidth(7, 15 * 256);
            sheet1.SetColumnWidth(8, 15 * 270);
            sheet1.SetColumnWidth(9, 15 * 270);
            sheet1.SetColumnWidth(10, 15 * 256);
            //设置第一行
            IRow row0 = sheet1.CreateRow(0);
            //行高
            row0.Height = 30 * 20;
            //合并单元格
            sheet1.AddMergedRegion(new CellRangeAddress(0, 0, 0, 10));
            //创建单元格
            CreateCell(row0, 0, Getcellstyle(book, "center", false, 14, 300), Section + "三类人员台账");

            //第二行
            IRow row1 = sheet1.CreateRow(1);
            sheet1.AddMergedRegion(new CellRangeAddress(1, 1, 0, 4));
            sheet1.AddMergedRegion(new CellRangeAddress(1, 1, 5, 10));
            CreateCell(row1, 0, Getcellstyle(book, "left", false), "标段：" + Section);
            CreateCell(row1, 5, Getcellstyle(book, "right", false), "施工单位：" + unitname);



            //给sheet1添加第行的头部标题
            IRow row2 = sheet1.CreateRow(2);
            //行高
            row2.Height = 25 * 20;
            CreateCell(row2, 0, Getcellstyle(book, "center", true, 11, 600), "序号");
            CreateCell(row2, 1, Getcellstyle(book, "center", true, 11, 600), "姓名");
            CreateCell(row2, 2, Getcellstyle(book, "center", true, 11, 600), "性别");
            CreateCell(row2, 3, Getcellstyle(book, "center", true, 11, 600), "职务");
            CreateCell(row2, 4, Getcellstyle(book, "center", true, 11, 600), "证书编号");
            CreateCell(row2, 5, Getcellstyle(book, "center", true, 11, 600), "发证日期");
            CreateCell(row2, 6, Getcellstyle(book, "center", true, 11, 600), "证件有效期");
            CreateCell(row2, 7, Getcellstyle(book, "center", true, 11, 600), "资格类型");
            CreateCell(row2, 8, Getcellstyle(book, "center", true, 11, 600), "是/否面试合格");
            CreateCell(row2, 9, Getcellstyle(book, "center", true, 11, 600), "是/否变更人员");
            CreateCell(row2, 10, Getcellstyle(book, "center", true, 11, 600), "备注");

            //将数据逐步写入sheet1各个行
            for (int i = 0; i < list.Count; i++)
            {
                NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 3);
                CreateCell(rowtemp, 0, Getcellstyle(book), (i + 1).ToString());
                CreateCell(rowtemp, 1, Getcellstyle(book), list[i].Tp_Name);
                CreateCell(rowtemp, 2, Getcellstyle(book), list[i].Tp_Sex);
                CreateCell(rowtemp, 3, Getcellstyle(book), list[i].Tp_Post);
                CreateCell(rowtemp, 4, Getcellstyle(book), list[i].Tp_CertificateNumber);
                CreateCell(rowtemp, 5, Getcellstyle(book), list[i].Tp_IssueDate==null?"":Convert.ToDateTime(list[i].Tp_IssueDate).ToString("yyyy-MM-dd"));
                CreateCell(rowtemp, 6, Getcellstyle(book), list[i].Tp_ValidityDate==null?"":Convert.ToDateTime(list[i].Tp_ValidityDate).ToString("yyyy-MM-dd"));
                CreateCell(rowtemp, 7, Getcellstyle(book), list[i].Tp_QualificationType);
                CreateCell(rowtemp, 8, Getcellstyle(book), list[i].Tp_IsInterview == null ? "" : list[i].Tp_IsInterview == false ? "否" : "是");
                CreateCell(rowtemp, 9, Getcellstyle(book), list[i].Tp_IsChange == null ? "" : list[i].Tp_IsChange == false ? "否" : "是");
                CreateCell(rowtemp, 10, Getcellstyle(book), list[i].Tp_Remark);
            }
            // 写入到客户端 
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            string fileName = HttpUtility.UrlEncode("三类人员台账.xls", Encoding.GetEncoding("UTF-8"));
            return File(ms, "application/vnd.ms-excel", fileName);

        }
        /// <summary>
        /// Excel导入
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public JsonResult ImportExcelFile(HttpPostedFileBase FileData)
        {
            string infor = "";
            var isScuess = TryCatchCommand.TryExec(() =>
            {
                if (FileData != null)
                {
                    string tempFileName = FileData.FileName;
                    string fileExt = Path.GetExtension(tempFileName).ToLower();
                    string fileName = Guid.NewGuid().ToString() + fileExt;
                    string tempPath = "/TempleterFilePath";
                    if (!tempPath.EndsWith("/"))
                        tempPath += "/";
                    tempPath = Server.MapPath(tempPath);
                    if (!Directory.Exists(tempPath))
                        Directory.CreateDirectory(tempPath);
                    tempPath = Path.Combine(tempPath, fileName);
                    FileData.SaveAs(tempPath);
                    if (string.IsNullOrWhiteSpace(tempPath) || !System.IO.File.Exists(tempPath))
                    {
                        throw new Exception("导入文件不存在");
                    }
                    string Section = Request.QueryString["Section"];
                    HSSFWorkbook hssfworkbook;

                    //读取文件流
                    using (FileStream fs = System.IO.File.OpenRead(tempPath))
                    {
                        hssfworkbook = new HSSFWorkbook(fs);
                        //获取第一个工作簿
                        NPOI.SS.UserModel.ISheet sheet = hssfworkbook.GetSheetAt(0);
                        {
                            var ret = ExcelImportValidation.Validation<ScmThreepersonnelInfo>(sheet);
                            if (ret.Item1)
                            {
                                //获取第一行
                                IRow headerRow = sheet.GetRow(0);
                                //列数
                                int cellCount = headerRow.LastCellNum;
                                //行数
                                int rowCount = sheet.LastRowNum;
                                //循环行
                                for (int i = 1; i <= rowCount; i++)
                                {
                                    IRow row = sheet.GetRow(i);
                                    //整体风险评估台账
                                    //ScmRiskassessInfo info = new ScmRiskassessInfo();
                                    ScmThreepersonnelInfo info = new ScmThreepersonnelInfo();
                                    info.Tp_ID = Guid.NewGuid().ToString();
                                    info.Tp_Section = Section;
                                    ProjectUnitInfo uInfo = GetUnitInfoByCode(Section);
                                    info.Tp_UnitID = uInfo.UNIT_ID;
                                    info.Tp_UnitName = uInfo.UNIT_NAME;
                                    info.Tp_Time = DateTime.Now;
                                    //操作人ID及名称 添加权限时赋值
                                    info.Tp_UserID = GetLoginUserId;
                                    info.Tp_UserName = GetLoginUserRealName;
                                    //读取该行信息
                                    info.Tp_Name = GetCellValue(row.GetCell(0));
                                    info.Tp_Sex = GetCellValue(row.GetCell(1));
                                    info.Tp_Post = GetCellValue(row.GetCell(2));
                                    info.Tp_CertificateNumber = GetCellValue(row.GetCell(3));
                                    DateTime? TimeNull = null;
                                    info.Tp_IssueDate = string.IsNullOrEmpty(GetCellValue(row.GetCell(4))) ? TimeNull : Convert.ToDateTime(GetCellValue(row.GetCell(4)));
                                    info.Tp_ValidityDate = string.IsNullOrEmpty(GetCellValue(row.GetCell(5))) ? TimeNull : Convert.ToDateTime(GetCellValue(row.GetCell(5)));
                                    info.Tp_QualificationType = GetCellValue(row.GetCell(6));
                                    bool? BoolNull = null;
                                    info.Tp_IsInterview = GetCellValue(row.GetCell(7)) == "" ? BoolNull : GetCellValue(row.GetCell(7)) == "是" ? true : false;
                                    info.Tp_IsChange = GetCellValue(row.GetCell(8)) == "" ? BoolNull : GetCellValue(row.GetCell(8)) == "是" ? true : false;
                                    info.Tp_Remark = GetCellValue(row.GetCell(9));

                                    //向数据库插入数据
                                    //ScmRiskassessUIRule.AddRiskassess(info);
                                    ScmThreepersonnelUIRule.InsertEntity(info);
                                }
                            }
                            else
                            {
                                infor = ret.Item2;
                            }
                        }
                    }
                    //删除临时文件
                    System.IO.File.Delete(tempPath);
                }
               
            });
            dynamic jsonReturn = new ExpandoObject();
            //保存成功
            if (isScuess)
            {
                if (infor == "")
                {
                    jsonReturn = new
                    {
                        statusCode = "200",
                        message = "导入成功",
                        navTabId = "",
                        rel = "",
                        callbackType = "",
                        forwardUrl = "",
                        confirmMsg = ""
                    };
                }
                else
                {
                    jsonReturn = new
                    {
                        statusCode = "300",
                        message = "导入失败!  " + infor,
                    };
                }
            }
            else
            {
                jsonReturn = new
                {
                    statusCode = "300",
                    message = "导入失败",
                };
            }
            return new JsonResult()
            {
                Data = jsonReturn
            };
        }
        //public JsonResult ImportExcelFile(int[] datas)
        //{
        //    string infor = "";
        //    var isScuess = TryCatchCommand.TryExec(() =>
        //    {
        //        string Section = Request.Form["Section"];
        //        HSSFWorkbook hssfworkbook;

        //        var bytes = datas.ToList().ConvertAll(x => (byte)x).ToArray();
        //        //读取文件流
        //        using (Stream file = new MemoryStream(bytes))
        //        {
        //            hssfworkbook = new HSSFWorkbook(file);
        //        }
        //        //获取第一个工作簿
        //        NPOI.SS.UserModel.ISheet sheet = hssfworkbook.GetSheetAt(0);
        //        {
        //             var ret= ExcelImportValidation.Validation<ScmThreepersonnelInfo>(sheet);
        //             if (ret.Item1)
        //             {
        //                 //获取第一行
        //                 IRow headerRow = sheet.GetRow(0);
        //                 //列数
        //                 int cellCount = headerRow.LastCellNum;
        //                 //行数
        //                 int rowCount = sheet.LastRowNum;
        //                 //循环行
        //                 for (int i = 1; i <= rowCount; i++)
        //                 {
        //                     IRow row = sheet.GetRow(i);
        //                     //整体风险评估台账
        //                     //ScmRiskassessInfo info = new ScmRiskassessInfo();
        //                     ScmThreepersonnelInfo info = new ScmThreepersonnelInfo();
        //                     info.Tp_ID = Guid.NewGuid().ToString();
        //                     info.Tp_Section = Section;
        //                     ProjectUnitInfo uInfo = GetUnitInfoByCode(Section);
        //                     info.Tp_UnitID = uInfo.UNIT_ID;
        //                     info.Tp_UnitName = uInfo.UNIT_NAME;
        //                     info.Tp_Time = DateTime.Now;
        //                     //操作人ID及名称 添加权限时赋值
        //                     info.Tp_UserID = GetLoginUserId;
        //                     info.Tp_UserName = GetLoginUserRealName;
        //                     //读取该行信息
        //                     info.Tp_Name = GetCellValue(row.GetCell(0));
        //                     info.Tp_Sex = GetCellValue(row.GetCell(1));
        //                     info.Tp_Post = GetCellValue(row.GetCell(2));
        //                     info.Tp_CertificateNumber = GetCellValue(row.GetCell(3));
        //                     DateTime? TimeNull = null;
        //                     info.Tp_IssueDate = string.IsNullOrEmpty(GetCellValue(row.GetCell(4))) ? TimeNull : Convert.ToDateTime(GetCellValue(row.GetCell(4)));
        //                     info.Tp_ValidityDate = string.IsNullOrEmpty(GetCellValue(row.GetCell(5))) ? TimeNull : Convert.ToDateTime(GetCellValue(row.GetCell(5)));
        //                     //info.Tp_ValidityDate = GetCellValue(row.GetCell(5));
        //                     //if (string.IsNullOrEmpty(GetCellValue(row.GetCell(4))))
        //                     //{
        //                     //    info.Tp_IssueDate = null;
        //                     //}
        //                     //else
        //                     //{
        //                     //    info.Tp_IssueDate = Convert.ToDateTime(GetCellValue(row.GetCell(4)));
        //                     //}
        //                     //if (string.IsNullOrEmpty(GetCellValue(row.GetCell(5))))
        //                     //{
        //                     //    info.Tp_ValidityDate = null;
        //                     //}
        //                     //else
        //                     //{
        //                     //    info.Tp_ValidityDate = Convert.ToDateTime(GetCellValue(row.GetCell(5)));
        //                     //}  
        //                     info.Tp_QualificationType = GetCellValue(row.GetCell(6));
        //                     bool? BoolNull = null;
        //                     info.Tp_IsInterview = GetCellValue(row.GetCell(7)) == "" ? BoolNull : GetCellValue(row.GetCell(7)) == "是" ? true : false;
        //                     info.Tp_IsChange = GetCellValue(row.GetCell(8)) == "" ? BoolNull : GetCellValue(row.GetCell(8)) == "是" ? true : false;
        //                     info.Tp_Remark = GetCellValue(row.GetCell(9));

        //                     //向数据库插入数据
        //                     //ScmRiskassessUIRule.AddRiskassess(info);
        //                     ScmThreepersonnelUIRule.InsertEntity(info);
        //                 }
        //             }
        //             else
        //             {
        //                 infor = ret.Item2;
        //             }
        //        }
        //    });
        //    dynamic jsonReturn = new ExpandoObject();
        //    //保存成功
        //    if (isScuess)
        //    {
        //        if (infor == "")
        //        {
        //            jsonReturn = new
        //            {
        //                statusCode = "200",
        //                message = "导入成功",
        //                navTabId = "",
        //                rel = "",
        //                callbackType = "",
        //                forwardUrl = "",
        //                confirmMsg = ""
        //            };
        //        }
        //        else
        //        {
        //            jsonReturn = new
        //            {
        //                statusCode = "300",
        //                message = "导入失败!  " + infor,
        //            };
        //        }
        //    }
        //    else
        //    {
        //        jsonReturn = new
        //        {
        //            statusCode = "300",
        //            message = "导入失败",
        //        };
        //    }
        //    return new JsonResult()
        //    {
        //        Data = jsonReturn
        //    };
        //}
        #endregion
    }
}
